<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
</head>
<style>
table {
  border:1px solid #ccc;
	}
	table td, table th {
	  border-bottom: 1px solid #ccc;
	  border-right: 1px solid #ccc;
	  padding: 3px 5px;
	}
	table th {
	  text-align: center;
	}			
	
</style>
	<main class="outline" id="container">
	<div class="main huodong">
		<div class="huodong_title">
			<h1>活动专区</h1>
		</div>
		<div class="huodong_main">
			<div class="box">
				<div class="accordion-header">
					<input style="display: none"  class="id" value=""/>
					<div class="show_box">
						<div class="left img_box">
							<img src="" width="660" height="150" alt="">
						</div>
					</div>
					<div class="finsh_mark" style="display: none"></div>
				</div>
			</div>
		</div>
	</div>
	</main>
<script type="text/javascript">

	function newActiveItem(item) {
		var html = "<div class='box'>"+
		"<input style='display: none'  name='id' value='"+ item.id+"'/>"+
		"<div class='accordion-heade'r>"+
		"<div class='show_box'>"+
			"<div class='left img_box'>"+
				"<img src='/d/cp/"+item.photo_path+"'"+
					"width='660' height='150' alt=''>"+
			"</div>"+
			"<div class='right box_info'>"+
				"<h1>"+
					"<i class='iconfont icon-gou'></i> <span>"+item.name+"</span>"+
				"</h1>"+
				"<div>"+
					"<i class='biaoji'></i>"+
					"<p style='white-space: normal;'>"+
						"<span style='font-family: 宋体, SimSun; font-size: 12px;'>活动对象：所有会员<br></span>"+
					"</p>"+
					"<i class='biaoji'></i>"+
					"<p style='white-space: normal;'>"+
						"<span style='font-family: 宋体, SimSun; font-size: 12px;'>活动简介："+item.name+"</span>"+
						"</p>"+
					"</div>"+
				"</div>"+
			"</div>"+
			"<div class='finsh_mark' style='display: none'></div>"+
		"</div>"+
		"<div class='content_box accordion-content' style='display: none'>"+
		"</div>"+
		"</div>"
		return html
	}
	$(".huodong_main").on("click",".box",function(e){
		var id = $(this).find("input[name='id']").val()
		if($(this).find(".accordion-content")[0].style.display=="block"){
			$(this).find(".accordion-content")[0].style.display="none"; 
		}else{
			$(this).find(".accordion-content")[0].style.display="block";
		}
		var content = $(this).find(".accordion-content")
		$.ajax({
		url: "/act/oneActivity.do",
		type: "post",
		data: {id: id},
		success: function(data) {
			var dataObj = data.data
			content.html(dataObj.alert1)
		},
		error: function(status) {
			bindLayerLittle("提示：", "网络繁忙")
		}
		})
		
	});
	function initActivityList(data) {
		var $noticeList = $(".huodong_main")
		$noticeList.html("")
		for (var i = 0; i < data.length; i++) {
			var html = newActiveItem(data[i])
			$noticeList.append(html)
		}
	}	
	$.ajax({
		url: "/act/allActivity.do",
		type: "post",
		data: {},
		success: function(data) {
			if (data.data.length === 0) {
				$("#div-i-noticeList").html("<p style='text-align:center;'>暂无正在进行中的优惠活动</p>")				
			} else {
				initActivityList(data.data)
			}
		},
		error: function(status) {
			bindLayerLittle("提示：", "网络繁忙")
		}
	}) 
</script>
